package com.craftplay.service;


import com.craftplay.dao.PageMapper;
import com.craftplay.dao.RecommendMapper;
import com.craftplay.model.Content;
import com.craftplay.model.Recommend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecommendService {

    @Autowired
    RecommendMapper recommendMapper;

    @Autowired
    PageMapper pageMapper;

    public int insertOneRecord(Recommend recommend) {
        return recommendMapper.insert(recommend.getOpenId(), recommend.getUserId());
    }

    public List<Recommend> selectByUserId(int userId) {
        return recommendMapper.selectByUserId(userId);
    }

    public Recommend selectByOpenId(String openId) {
        return recommendMapper.selectByOpenId(openId);
    }


    //获取配置内容
    public List<Content> getContent(String type) {
        Content content = new Content();
        content.setType(type);
        return pageMapper.getContentList(content);
    }

}
